import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-admin/area/page/storage/management',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

// 新增仓库 储位
export const add = (data) => {
  return request({
    url: '/api/mes-admin/area/submit/storage/management',
    method: 'post',
    data: data
  });
};

export const detail = (params) => {
  return request({
    url: '/api/mes-admin/area/detail/storage/management',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const remove = (id) => {
  return request({
    url: `/api/mes-admin/area/remove/storage/management?ids=${id}`,
    method: 'post'
  });
};

export const update = (data) => {
  return request({
    url: '/api/mes-admin/area/submit/storage/management',
    method: 'post',
    data: data
  });
};

export const getChildrenNode = (params) => {
  return request({
    url: '/api/mes-admin/area/select/storage/management',
    method: 'get',
    params: {
      ...params
    }
  });
};

//打印
export const print = (row) => {
  return request({
    url: '/api/mes-admin/area/print',
    method: 'post',
    data: row
  });
};

export const getExprot = (data) => {
  return request({
    url: '/api/mes-admin/area/export/storage/management',
    method: 'GET',
    responseType: 'blob'
  });
};

// MES V8.6

export const getWareHouseList = (current, size, params) => {
  return request({
    url: '/api/mes-warehouse/warehouse/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getAreaList = (current, size, params) => {
  return request({
    url: '/api/mes-warehouse/area/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getStorageList = (current, size, params) => {
  return request({
    url: '/api/mes-warehouse/storage/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getWareHouseDetail = (id) => {
  return request({
    url: '/api/mes-warehouse/warehouse/detail',
    method: 'get'
  });
};

export const getWarehouseDetail = (id) => {
  return request({
    url: '/api/mes-warehouse/warehouse/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getStorageDetail = (id) => {
  return request({
    url: '/api/mes-warehouse/storage/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const getAreaDetail = (id) => {
  return request({
    url: '/api/mes-warehouse/area/detail',
    method: 'get',
    params: {
      id
    }
  });
};

export const checkStorage = (code) => {
  return request({
    url: '/api/mes-warehouse/storage/check',
    method: 'get',
    params: {
      code
    }
  });
};

export const checkArea = (code) => {
  return request({
    url: '/api/mes-warehouse/area/check',
    method: 'get',
    params: {
      code
    }
  });
};

export const delWarehouse = (id) => {
  return request({
    url: '/api/mes-warehouse/warehouse/remove',
    method: 'post',
    params: {
      id
    }
  });
};

export const delArea = (id) => {
  return request({
    url: '/api/mes-warehouse/area/remove',
    method: 'post',
    params: {
      id
    }
  });
};

export const delStorage = (id) => {
  return request({
    url: '/api/mes-warehouse/storage/remove',
    method: 'post',
    params: {
      id
    }
  });
};

export const updateWarehouse = (data) => {
  return request({
    url: '/api/mes-warehouse/warehouse/submit',
    method: 'post',
    data
  });
};

export const updateArea = (data) => {
  return request({
    url: '/api/mes-warehouse/area/submit',
    method: 'post',
    data
  });
};

export const updateStorage = (data) => {
  return request({
    url: '/api/mes-warehouse/storage/submit',
    method: 'post',
    data
  });
};
